<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(nums, k) {
      return nums.sort((a, b) => b.length - a.length || (b > a ? 1 : -1))[k - 1]
    };
    console.log(arr(["3", "6", "7", "10"], 4));
  </script>
</body>

</html>